-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add links and some examples to std::sync::mpsc docs #40981
Conversation
This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`, `Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`, `RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`, `SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`, `Receiver::iter`, and `Receiver::try_iter`. Examples added to `Receiver`, `Sender`, `Receiver::iter`.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Travis found some errors https://gist.github.com/frewsxcv/d968eb5970f2d7530fc6c86c723c95a5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! This is great, I just have a few minor style nits. We don't use ()
s for function names, and some extra whitespace will make these examples more readable. Thank you!
src/libstd/sync/mpsc/mod.rs
Outdated
//! senders are clone-able (multi-producer) such that many threads can send | ||
//! simultaneously to one receiver (single-consumer). | ||
//! | ||
//! These channels come in two flavors: | ||
//! | ||
//! 1. An asynchronous, infinitely buffered channel. The `channel()` function | ||
//! 1. An asynchronous, infinitely buffered channel. The [`channel()`] function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you're adapting existing text here, but the style is to drop the ()
s. Would you mind doing that as well please?
src/libstd/sync/mpsc/mod.rs
Outdated
//! 2. A synchronous, bounded channel. The `sync_channel()` function will return | ||
//! a `(SyncSender, Receiver)` tuple where the storage for pending messages | ||
//! is a pre-allocated buffer of a fixed size. All sends will be | ||
//! 2. A synchronous, bounded channel. The [`sync_channel()`] function will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/libstd/sync/mpsc/mod.rs
Outdated
//! [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html | ||
//! [`send`]: ../../../std/sync/mpsc/struct.Sender.html#method.send | ||
//! [`channel()`]: ../../../std/sync/mpsc/fn.channel.html | ||
//! [`sync_channel()`]: ../../../std/sync/mpsc/fn.sync_channel.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and both of these lines to match
src/libstd/sync/mpsc/mod.rs
Outdated
//! continue to `unwrap()` the results returned from this module, instigating a | ||
//! propagation of failure among threads if one unexpectedly dies. | ||
//! continue to make progress, so [`Err`] will be returned. Many applications | ||
//! will continue to [`unwrap()`] the results returned from this module, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
src/libstd/sync/mpsc/mod.rs
Outdated
//! | ||
//! [`Result`]: ../../../std/result/enum.Result.html | ||
//! [`Err`]: ../../../std/result/enum.Result.html#variant.Err | ||
//! [`unwrap()`]: ../../../std/result/enum.Result.html#method.unwrap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
src/libstd/sync/mpsc/mod.rs
Outdated
/// thread::spawn(move || { | ||
/// sender.send(1).unwrap(); | ||
/// }); | ||
/// // Second thread owns sender2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and one above here
src/libstd/sync/mpsc/mod.rs
Outdated
/// thread::spawn(move || { | ||
/// sender2.send(2).unwrap(); | ||
/// }); | ||
/// let msg = receiver.recv().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and one above here
src/libstd/sync/mpsc/mod.rs
Outdated
/// }); | ||
/// let msg = receiver.recv().unwrap(); | ||
/// let msg2 = receiver.recv().unwrap(); | ||
/// assert_eq!(3, msg + msg2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and one above here, please!
src/libstd/sync/mpsc/mod.rs
Outdated
/// ```rust | ||
/// use std::sync::mpsc::channel; | ||
/// use std::thread; | ||
/// let (send, recv) = channel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one blank line above and below this line, please!
src/libstd/sync/mpsc/mod.rs
Outdated
/// send.send(2u8).unwrap(); | ||
/// send.send(3u8).unwrap(); | ||
/// }); | ||
/// for x in recv.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and one above here
@bors: r+ rollup Thanks! |
📌 Commit ab4f442 has been approved by |
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Addresses part of #29377
r? @steveklabnik
I took a stab at adding links to the
std::sync::mpsc
docs, and I also wrote a few examples.Edit: Whoops, typed in
?r
instead ofr?
.